<template>
  <div class="header">
    <div class="header-title">碧丽智慧物联网数据监控平台</div>
    <div class="header-logo">
      <img src="@/assets/user-logo.png" alt="广东碧丽饮水设备有限公司" />广东碧丽饮水设备有限公司
    </div>
    <div class="header-time">
      <img src="@/assets/logo.png" alt="建网科技" />
      <div>{{ nowDay + ' ' + nowTime }}</div>
    </div>
  </div>
</template>

<script lang="ts" setup name="Header">
import { parseTime } from '@/utils'
import { onMounted, onUnmounted, ref } from 'vue'
const nowDay = ref('')
const nowTime = ref('')
const timer = ref()
// 开启定时器
const handleTime = () => {
  nowDay.value = parseTime(new Date(), '{y}-{m}-{d}')
  timer.value = setInterval(() => {
    nowTime.value = parseTime(new Date(), '{h}:{i}:{s}')
  }, 1000)
}

onMounted(() => {
  handleTime()
})
onUnmounted(() => {
  clearInterval(timer.value)
})
</script>

<style lang="scss" scoped>
.header-bg {
  position: absolute;
  width: 100%;
  height: 80px;
  background-image: url('@/assets/top_bg.png');
  background-size: 100% 100%;
  opacity: 0.5;
}

.header {
  width: 100vw;
  position: relative;
  height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  justify-content: center;
}
.header-logo {
  color: #ffffff;
  display: flex;
  align-items: center;
  height: auto;
  position: absolute;
  top: 38px;
  left: 20px;
  font-size: 18px;
  img {
    width: 20px;
    height: 22px;
    margin-right: 10px;
  }
}
.header-title {
  font-size: 32px;
  color: #73e6f4;
}

.header-time {
  position: absolute;
  top: 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  right: 20px;
  font-size: 12px;
  color: #ffffff;
  img {
    margin-bottom: 6px;
    width: 100px;
    height: auto;
  }
}
</style>
